<!doctype html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>Document</title>
	<meta name="csrf-token" content="{{ csrf_token() }}">
</head>
<body>
	<h1>CSRF 保护</h1>
	<form action="/insert" method="post">
		<!-- <?php// echo csrf_field(); ?> -->
		{{ csrf_field() }}
		用户： <input type="text" name="username" value="">
		密码： <input type="text" name="password" value="">
		<input type="submit" value="提交">
	</form>
	<button> 使用ajax---post提交 </button>
	
	<script type="text/javascript" src="/js/jquery-1.8.3.min.js"></script>
	<script type="text/javascript">
		$('button').first().click(function(){

			$.ajaxSetup({
			        headers: {
			            'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
			        }
			});
			
			// $.post('url',{data},function(){},'json');
			// $.get();
			$.post('/insert',function(msg){
				alert(msg)
			});
		})
	</script>
</body>
</html>